package com.zc.operator.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.zc.custom.domain.ChargeCustomOrderEvaluation;
import com.zc.custom.mapper.ChargeCustomOrderEvaluationMapper;
import com.zc.operator.service.IChargeCustomOrderEvaluationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 用户订单评价Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-01
 */
@Service
public class ChargeCustomOrderEvaluationServiceImpl implements IChargeCustomOrderEvaluationService {
    @Autowired
    private ChargeCustomOrderEvaluationMapper chargeCustomOrderEvaluationMapper;

    /**
     * 查询用户订单评价
     *
     * @param id 用户订单评价主键
     * @return 用户订单评价
     */
    @Override
    public ChargeCustomOrderEvaluation selectChargeCustomOrderEvaluationById(Long id) {
        ChargeCustomOrderEvaluation chargeCustomOrderEvaluation = chargeCustomOrderEvaluationMapper.selectChargeCustomOrderEvaluationById(id);
        List<String> picList = new ArrayList<>();
        if (!StringUtils.isEmpty(chargeCustomOrderEvaluation.getPic())) {
            String[] split = chargeCustomOrderEvaluation.getPic().split(",");
            for (String s : split) {
                s = "https://www.sdzctech.cn" + s;
                picList.add(s);
            }
        }
        chargeCustomOrderEvaluation.setPicList(picList);
        return chargeCustomOrderEvaluation;
    }

    /**
     * 查询用户订单评价列表
     *
     * @param chargeCustomOrderEvaluation 用户订单评价
     * @return 用户订单评价
     */
    @Override
    public List<ChargeCustomOrderEvaluation> selectChargeCustomOrderEvaluationList(ChargeCustomOrderEvaluation chargeCustomOrderEvaluation) {
        List<ChargeCustomOrderEvaluation> chargeCustomOrderEvaluations = chargeCustomOrderEvaluationMapper.selectChargeCustomOrderEvaluationList(chargeCustomOrderEvaluation);
        for (ChargeCustomOrderEvaluation customOrderEvaluation : chargeCustomOrderEvaluations) {
            List<String> picList = new ArrayList<>();
            if (!StringUtils.isEmpty(customOrderEvaluation.getPic())) {
                String[] split = customOrderEvaluation.getPic().split(",");
                for (String s : split) {
                    s = "https://www.sdzctech.cn" + s;
                    picList.add(s);
                }
            }
            customOrderEvaluation.setPicList(picList);
        }
        return chargeCustomOrderEvaluations;
    }

    /**
     * 新增用户订单评价
     *
     * @param chargeCustomOrderEvaluation 用户订单评价
     * @return 结果
     */
    @Override
    public boolean insertChargeCustomOrderEvaluation(ChargeCustomOrderEvaluation chargeCustomOrderEvaluation) {
        chargeCustomOrderEvaluation.setCreateTime(DateUtils.getNowDate());
        return chargeCustomOrderEvaluationMapper.insertChargeCustomOrderEvaluation(chargeCustomOrderEvaluation);
    }

    /**
     * 修改用户订单评价
     *
     * @param chargeCustomOrderEvaluation 用户订单评价
     * @return 结果
     */
    @Override
    public boolean updateChargeCustomOrderEvaluation(ChargeCustomOrderEvaluation chargeCustomOrderEvaluation) {
        return chargeCustomOrderEvaluationMapper.updateChargeCustomOrderEvaluation(chargeCustomOrderEvaluation);
    }

    /**
     * 批量删除用户订单评价
     *
     * @param ids 需要删除的用户订单评价主键
     * @return 结果
     */
    @Override
    public int deleteChargeCustomOrderEvaluationByIds(Long[] ids) {
        return chargeCustomOrderEvaluationMapper.deleteChargeCustomOrderEvaluationByIds(ids);
    }

    /**
     * 删除用户订单评价信息
     *
     * @param id 用户订单评价主键
     * @return 结果
     */
    @Override
    public boolean deleteChargeCustomOrderEvaluationById(Long id) {
        return chargeCustomOrderEvaluationMapper.deleteChargeCustomOrderEvaluationById(id);
    }
}
